// components/monitor-item/monitor-item.ts
Component({
  /**
   * 组件的属性列表
   */
  properties: {
    item: Object
  },
  /**
   * 组件的初始数据
   */
  data: {
    noneStr: "无",
    actionInfo: [//跳转
      { key: "sxNum", name: "涉诉信息", path: "/subPackages/packageA/shesu/shesuDetail/shesuDetail" },
      { key: "zxNum", name: "失信执行人信息", path: "/subPackages/packageA/shesu/executorDetail/executorDetail" },
      { key: "countLimitHighconsume", name: "限制高消费信息", path: "/subPackages/packageA/shesu/consumptionDetail/consumptionDetail" },
      { key: "countFinalCase", name: "终本案件", path: "/subPackages/packageA/litigationDetail/litigationDetail" },
      { key: "countRegister", name: "立案信息", path: "/subPackages/packageA/litigationDetail/litigationDetail" },
      { key: "countNotice", name: "开庭公告", path: "/subPackages/packageA/litigationDetail/litigationDetail" },
      { key: "countAnnouncement", name: "法院公告", path: "/subPackages/packageA/litigationDetail/litigationDetail" },
      { key: "countEquityFreeze", name: "司法协助股权冻结", path: "/subPackages/packageA/shesu/freeze/freeze" },
      { key: "countAssistanceUnfreeze", name: "司法协助解除冻结", path: "/subPackages/packageA/shesu/unfreeze/unfreeze" },
      { key: "countAuction", name: "司法拍卖", path: "/subPackages/packageA/shesu/judicialAuction/judicialAuction" },
    ],
  },
  /**
   * 组件的方法列表
   */
  methods: {

    isSupportDetail(category: string): boolean {
      return category != "tax" && category != "industry" && category != "environmental" && category != "violation"
    },
    onCompanyNameClick() {
      this.goDebtorDetail()
    },
    onItemClick() {
      const item = this.properties.item
      const type = item.messageType
      console.log('item = ' + JSON.stringify(item))
      if (this.isSupportDetail(type)) {
        this.gotoDetail(type, item.id)
      }

    },
    goDebtorDetail() {
      const item = this.properties.item
      wx.navigateTo({
        url: "/subPackages/packageA/debotrDetail/debtorDetail?debtorId=" + item.debtorId + "&companyName=" + item.companyName
      })
    },
    gotoDetail(messageType: string, id: string) {

      const actionInfo = this.data.actionInfo
      let curAction = null
      switch (messageType) {
        case 'lawsuit'://涉诉
          curAction = actionInfo[0]
          break
        case 'trust'://失信
          curAction = actionInfo[1]
          break
        case 'limit'://限高
          curAction = actionInfo[2]
          break
        case 'finish'://终本
          curAction = actionInfo[3]
          break
        case 'put'://立案
          curAction = actionInfo[4]
          break
        case 'hearing'://开庭
          curAction = actionInfo[5]
          break
        case 'court'://法院
          curAction = actionInfo[6]
          break
        default: break
      }
      if (curAction) {
        console.log(curAction.path)
        wx.navigateTo({
          url: curAction.path + "?id=" + id + '&scene=' + curAction.key + '&navTitle=' + curAction.name
        })
      }
    },
  },
  //生命周期函数
  lifetimes: {
    created() { },
    attached() { },
    ready() { },
    moved() { },
    detached() { },
    error() { },
  },
  //组件所在页面的生命周期
  pageLifetimes: {
    show() { },
    hide() { },
    resize() { }
  }
})